<?php 

class Ext_Video_Fetch_Parse_Adapter_Tudou extends Ext_Video_Fetch_Parse_Abstract
{
    public function parse()
    {

        $this->_datas['host'] = "tudou.com";

        $iid = "";
        if(preg_match("/,defaultIid = ([0-9]+)/ui", $this->_html, $m) && $m[1]){
            $iid = $m[1];
        }elseif(preg_match("/,iid = ([0-9]+)/ui", $this->_html, $m) && $m[1]){
            $iid = $m[1];
        }
        
        
        if(preg_match("/,iid_code = icode = \'([^\"\']+?)\'/ui", $this->_html, $m) && $m[1]){
             $this->_datas['viewId'] = $m[1];
        }elseif(preg_match("/,icode:\"([^\"\']+?)\"/ui", $this->_html, $m) && $m[1]){      
             $this->_datas['viewId'] = $m[1];
        }
        
        $this->_datas['url'] = $this->_url;

        if(preg_match("/,ltitle = \"([^\"\']+?)\"/ui", $this->_html, $m) && $m[1]){
            $this->_datas['title'] = $m[1];
        }elseif(preg_match("/,kw = title = \"([^\"\']+?)\"/ui", $this->_html, $m) && $m[1]){
            $this->_datas['title'] = $m[1];
            
        }elseif(preg_match("/,atitle = \"([^\"\']+?)\"/ui", $this->_html, $m) && $m[1]){
            $this->_datas['title'] = $m[1];
            
        }

        if(preg_match("/".$iid.".*?pic\s*[\:\=]\s*[\"\']([^\"\']+?)[\"\']/si", $this->_html, $m) && $m[1]){
            $this->_datas['photo'] = $m[1];
            
        }
    }

}
